﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using TrackIT.Common.Utils;

namespace TrackIT.Common.Repositories
{
    [ExcludeFromCodeCoverage]
    internal sealed class MockWorkLogRepository : IWorkLogRepository
    {
        public IList<Task> TaskList;
        public int LoadCallCount;
        public int SaveCallCount;
        public int StartCallCount;
        public int StopCallCount;
        public WorkEntry CurrentWorkEntry;
        public WorkEntryType NextActionType;
        public TimeSpan TimeSpentOnTask { get; set; } 

        public MockWorkLogRepository()
        {
            LoadCallCount = 0;
            TaskList = new List<Task>();
            CurrentWorkEntry = new WorkEntry();
        }

        public void Load()
        {
            LoadCallCount++;
        }

        public void Save()
        {
            SaveCallCount++;
        }

        public WorkEntry Start(string task)
        {
            StartCallCount++;
            CurrentWorkEntry.Task = task;
            CurrentWorkEntry.Start = Util.RemoveUnecessarySecondsParts(DateTime.Now);
            return CurrentWorkEntry;
        }

        public WorkEntry Stop()
        {
            StopCallCount++;
            CurrentWorkEntry.Stop = Util.RemoveUnecessarySecondsParts(DateTime.Now);
            return CurrentWorkEntry;
        }

        public WorkEntry GetLast()
        {
            return CurrentWorkEntry;
        }

        public WorkEntryType GetNextActionType()
        {
            return NextActionType;
        }

        public IEnumerable<Task> Tasks
        {
            get { return TaskList; }
        }

        public WorkEntry Current
        {
            get { return CurrentWorkEntry; }
        }

        public Task GetTaskByName(string taskName)
        {
            return new Task(taskName);
        }

        public TimeSpan GetTimeSpentOnTask(string taskName)
        {
            return TimeSpentOnTask;
        }

        public List<string> GetWorkSummary(FilterDates filterDates)
        {
            throw new NotImplementedException();
        }


        public string GetTemporaryFolderName(ReportType reportType)
        {
            throw new NotImplementedException(); 
        }

        public string GetReportName(ReportType reportType)
        {
            throw new NotImplementedException();
        }


        public FilterDates ResolveDatesFromReportType(ReportType reportType)
        {
            throw new NotImplementedException();
        }


        public IEnumerable<WorkEntry> WorkItems
        {
            get { throw new NotImplementedException(); }
        }
    }
}
